The error-occurred probability in a semiconductor memory differs according to patterns of data to be programmed. For this reason, when user data is encoded into a highly reliable pattern and programmed to a semiconductor memory, the reliability of the programmed data can be enhanced.